package com.socket;

import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.HashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadPoolExecutor;

public class SocketServer {
	
	public static void main(String[] args) {
		try {
			// 创建服务端socket
			ServerSocket serverSocket = new ServerSocket(8088);
			
			// 创建客户端socket
			Socket socket = new Socket();
            ExecutorService executorService = Executors.newCachedThreadPool();
            ExecutorService executorService1 = Executors.newFixedThreadPool(10);
            ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(10);
            ExecutorService executorService2 = Executors.newSingleThreadExecutor();
            //循环监听等待客户端的连接
            while(true){
            	// 监听客户端
            	socket = serverSocket.accept();
            	ServerThread thread = new ServerThread(socket);
            	thread.start();
            	
            	InetAddress address=socket.getInetAddress();
                System.out.println("当前客户端的IP："+address.getHostAddress());
                new HashMap<>();
            }
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}
 
}